package com.xpxrule.controller.manage;

import com.xpxrule.dataobject.biz.model.ReturnResponse;
import com.xpxrule.dataobject.req.ModelItemQueryReq;
import com.xpxrule.dataobject.vo.ModelItemVo;
import com.xpxrule.service.ModelItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/modelItem")
public class ModelItemController {
    @Autowired
    private ModelItemService modelItemService;

    /**
     * 新增模型字段
     * @param vo
     * @return
     */
    @PostMapping("/insert")
    public ReturnResponse<Integer> insert(@RequestBody ModelItemVo vo) {
        return modelItemService.insert(vo);
    }

    /**
     * 根据id删除模型字段
     * @param id
     * @return
     */
    @GetMapping("/delete/{id}")
    public ReturnResponse<Integer> delete(@PathVariable("id") Long id) {
        return modelItemService.delete(id);
    }

    /**
     * 根据id更新模型字段
     * @param vo
     * @return
     */
    @PostMapping("/update")
    public ReturnResponse<Integer> update(@RequestBody ModelItemVo vo) {
        return modelItemService.update(vo);
    }

    /**
     * 根据查询条件查询模型字段列表
     * @param req
     * @return
     */
    @PostMapping("/selectList/byQuery")
    public ReturnResponse<List<ModelItemVo>> selectList(@RequestBody ModelItemQueryReq req) {
        return modelItemService.selectList(req);
    }
}
